package main

import (
	"fmt"
	"reflect"
	"strconv"
)

type T struct {
	A int
	B string
}

func main() {
	var x float64 = 3.4
	//v:=reflect.ValueOf(x)
	//fmt.Println("type:",v.Type())
	//fmt.Println("kind:",v.Kind())
	//fmt.Println("Value:",v.Float())
	//fmt.Println("type:",reflect.TypeOf(x))

	p := reflect.ValueOf(&x)

	fmt.Println("type of p:", p.Type())
	fmt.Println("set of p:", p.CanSet())

	v := p.Elem()

	fmt.Println("set of a:", v.CanSet())
	v.SetFloat(7.1)
	fmt.Println(v.Interface())
	fmt.Println(x)

	fmt.Println("--------------------")
	t := T{203, "ROM203"}
	t1 := &T{204, "ROM204"}
	t2 := &T{204, "ROM204"}
	fmt.Println(t1 == t2)
	fmt.Println(t1)
	s := reflect.ValueOf(&t).Elem()
	typeOfT := s.Type()

	for i := 0; i < s.NumField(); i++ {
		f := s.Field(i)
		fmt.Printf("%d: %s %s = %v\n", i, typeOfT.Field(i).Name, f.Type(), f.Interface())
	}


}
